package com.ghy.versionsone;
/**
 * 提供对外访问的简易API接口
 */
public class GhySqlSession {
    private GhyConfiguration configuration;
    private GhyExecutor executor;

    public GhySqlSession(){
        if(executor == null){
            executor = new GhyExecutor();
        }
        if(configuration == null){
            configuration = new GhyConfiguration();
        }
    }

    /**
     * 对外提供的查询的方法
     * @param <T>
     * @return
     */
    public <T> T selectOne(String statementId,Object parameter){

        String sql = GhyConfiguration.sqlMappings.getString(statementId);
        if (null !=sql && !"".equals ( sql )){
            return executor.query(sql,parameter);
        }
        return null;
    }
    //获取代理对象
    public <T> T getMapper(Class clazz){
        return configuration.getMapper(clazz,this);
    }
}
